﻿using Microsoft.EntityFrameworkCore.Migrations;

namespace MPACore.Phonebook.Migrations
{
    public partial class Ignore_User_Surname : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_AbpEntityChanges_AbpEntityChangeSets_EntityChangeSetId",
                table: "AbpEntityChanges");

            migrationBuilder.DropForeignKey(
                name: "FK_AbpEntityPropertyChanges_AbpEntityChanges_EntityChangeId",
                table: "AbpEntityPropertyChanges");

            migrationBuilder.DropForeignKey(
                name: "FK_AbpFeatures_AbpEditions_EditionId",
                table: "AbpFeatures");

            migrationBuilder.DropForeignKey(
                name: "FK_AbpOrganizationUnits_AbpOrganizationUnits_ParentId",
                table: "AbpOrganizationUnits");

            migrationBuilder.DropForeignKey(
                name: "FK_AbpPermissions_AbpRoles_RoleId",
                table: "AbpPermissions");

            migrationBuilder.DropForeignKey(
                name: "FK_AbpPermissions_AbpUsers_UserId",
                table: "AbpPermissions");

            migrationBuilder.DropForeignKey(
                name: "FK_AbpRoleClaims_AbpRoles_RoleId",
                table: "AbpRoleClaims");

            migrationBuilder.DropForeignKey(
                name: "FK_AbpRoles_AbpUsers_CreatorUserId",
                table: "AbpRoles");

            migrationBuilder.DropForeignKey(
                name: "FK_AbpRoles_AbpUsers_DeleterUserId",
                table: "AbpRoles");

            migrationBuilder.DropForeignKey(
                name: "FK_AbpRoles_AbpUsers_LastModifierUserId",
                table: "AbpRoles");

            migrationBuilder.DropForeignKey(
                name: "FK_AbpSettings_AbpUsers_UserId",
                table: "AbpSettings");

            migrationBuilder.DropForeignKey(
                name: "FK_AbpTenants_AbpUsers_CreatorUserId",
                table: "AbpTenants");

            migrationBuilder.DropForeignKey(
                name: "FK_AbpTenants_AbpUsers_DeleterUserId",
                table: "AbpTenants");

            migrationBuilder.DropForeignKey(
                name: "FK_AbpTenants_AbpEditions_EditionId",
                table: "AbpTenants");

            migrationBuilder.DropForeignKey(
                name: "FK_AbpTenants_AbpUsers_LastModifierUserId",
                table: "AbpTenants");

            migrationBuilder.DropForeignKey(
                name: "FK_AbpUserClaims_AbpUsers_UserId",
                table: "AbpUserClaims");

            migrationBuilder.DropForeignKey(
                name: "FK_AbpUserLogins_AbpUsers_UserId",
                table: "AbpUserLogins");

            migrationBuilder.DropForeignKey(
                name: "FK_AbpUserRoles_AbpUsers_UserId",
                table: "AbpUserRoles");

            migrationBuilder.DropForeignKey(
                name: "FK_AbpUsers_AbpUsers_CreatorUserId",
                table: "AbpUsers");

            migrationBuilder.DropForeignKey(
                name: "FK_AbpUsers_AbpUsers_DeleterUserId",
                table: "AbpUsers");

            migrationBuilder.DropForeignKey(
                name: "FK_AbpUsers_AbpUsers_LastModifierUserId",
                table: "AbpUsers");

            migrationBuilder.DropForeignKey(
                name: "FK_AbpUserTokens_AbpUsers_UserId",
                table: "AbpUserTokens");

            migrationBuilder.DropPrimaryKey(
                name: "PK_AbpUserTokens",
                table: "AbpUserTokens");

            migrationBuilder.DropPrimaryKey(
                name: "PK_AbpUsers",
                table: "AbpUsers");

            migrationBuilder.DropPrimaryKey(
                name: "PK_AbpUserRoles",
                table: "AbpUserRoles");

            migrationBuilder.DropPrimaryKey(
                name: "PK_AbpUserOrganizationUnits",
                table: "AbpUserOrganizationUnits");

            migrationBuilder.DropPrimaryKey(
                name: "PK_AbpUserNotifications",
                table: "AbpUserNotifications");

            migrationBuilder.DropPrimaryKey(
                name: "PK_AbpUserLogins",
                table: "AbpUserLogins");

            migrationBuilder.DropPrimaryKey(
                name: "PK_AbpUserLoginAttempts",
                table: "AbpUserLoginAttempts");

            migrationBuilder.DropPrimaryKey(
                name: "PK_AbpUserClaims",
                table: "AbpUserClaims");

            migrationBuilder.DropPrimaryKey(
                name: "PK_AbpUserAccounts",
                table: "AbpUserAccounts");

            migrationBuilder.DropPrimaryKey(
                name: "PK_AbpTenants",
                table: "AbpTenants");

            migrationBuilder.DropPrimaryKey(
                name: "PK_AbpTenantNotifications",
                table: "AbpTenantNotifications");

            migrationBuilder.DropPrimaryKey(
                name: "PK_AbpSettings",
                table: "AbpSettings");

            migrationBuilder.DropPrimaryKey(
                name: "PK_AbpRoles",
                table: "AbpRoles");

            migrationBuilder.DropPrimaryKey(
                name: "PK_AbpRoleClaims",
                table: "AbpRoleClaims");

            migrationBuilder.DropPrimaryKey(
                name: "PK_AbpPermissions",
                table: "AbpPermissions");

            migrationBuilder.DropPrimaryKey(
                name: "PK_AbpOrganizationUnits",
                table: "AbpOrganizationUnits");

            migrationBuilder.DropPrimaryKey(
                name: "PK_AbpNotificationSubscriptions",
                table: "AbpNotificationSubscriptions");

            migrationBuilder.DropPrimaryKey(
                name: "PK_AbpNotifications",
                table: "AbpNotifications");

            migrationBuilder.DropPrimaryKey(
                name: "PK_AbpLanguageTexts",
                table: "AbpLanguageTexts");

            migrationBuilder.DropPrimaryKey(
                name: "PK_AbpLanguages",
                table: "AbpLanguages");

            migrationBuilder.DropPrimaryKey(
                name: "PK_AbpFeatures",
                table: "AbpFeatures");

            migrationBuilder.DropPrimaryKey(
                name: "PK_AbpEntityPropertyChanges",
                table: "AbpEntityPropertyChanges");

            migrationBuilder.DropPrimaryKey(
                name: "PK_AbpEntityChangeSets",
                table: "AbpEntityChangeSets");

            migrationBuilder.DropPrimaryKey(
                name: "PK_AbpEntityChanges",
                table: "AbpEntityChanges");

            migrationBuilder.DropPrimaryKey(
                name: "PK_AbpEditions",
                table: "AbpEditions");

            migrationBuilder.DropPrimaryKey(
                name: "PK_AbpBackgroundJobs",
                table: "AbpBackgroundJobs");

            migrationBuilder.DropPrimaryKey(
                name: "PK_AbpAuditLogs",
                table: "AbpAuditLogs");

            migrationBuilder.DropColumn(
                name: "Surname",
                table: "AbpUsers");

            migrationBuilder.RenameTable(
                name: "AbpUserTokens",
                newName: "PhonebookUserTokens");

            migrationBuilder.RenameTable(
                name: "AbpUsers",
                newName: "PhonebookUsers");

            migrationBuilder.RenameTable(
                name: "AbpUserRoles",
                newName: "PhonebookUserRoles");

            migrationBuilder.RenameTable(
                name: "AbpUserOrganizationUnits",
                newName: "PhonebookUserOrganizationUnits");

            migrationBuilder.RenameTable(
                name: "AbpUserNotifications",
                newName: "PhonebookUserNotifications");

            migrationBuilder.RenameTable(
                name: "AbpUserLogins",
                newName: "PhonebookUserLogins");

            migrationBuilder.RenameTable(
                name: "AbpUserLoginAttempts",
                newName: "PhonebookUserLoginAttempts");

            migrationBuilder.RenameTable(
                name: "AbpUserClaims",
                newName: "PhonebookUserClaims");

            migrationBuilder.RenameTable(
                name: "AbpUserAccounts",
                newName: "PhonebookUserAccounts");

            migrationBuilder.RenameTable(
                name: "AbpTenants",
                newName: "PhonebookTenants");

            migrationBuilder.RenameTable(
                name: "AbpTenantNotifications",
                newName: "PhonebookTenantNotifications");

            migrationBuilder.RenameTable(
                name: "AbpSettings",
                newName: "PhonebookSettings");

            migrationBuilder.RenameTable(
                name: "AbpRoles",
                newName: "PhonebookRoles");

            migrationBuilder.RenameTable(
                name: "AbpRoleClaims",
                newName: "PhonebookRoleClaims");

            migrationBuilder.RenameTable(
                name: "AbpPermissions",
                newName: "PhonebookPermissions");

            migrationBuilder.RenameTable(
                name: "AbpOrganizationUnits",
                newName: "PhonebookOrganizationUnits");

            migrationBuilder.RenameTable(
                name: "AbpNotificationSubscriptions",
                newName: "PhonebookNotificationSubscriptions");

            migrationBuilder.RenameTable(
                name: "AbpNotifications",
                newName: "PhonebookNotifications");

            migrationBuilder.RenameTable(
                name: "AbpLanguageTexts",
                newName: "PhonebookLanguageTexts");

            migrationBuilder.RenameTable(
                name: "AbpLanguages",
                newName: "PhonebookLanguages");

            migrationBuilder.RenameTable(
                name: "AbpFeatures",
                newName: "PhonebookFeatures");

            migrationBuilder.RenameTable(
                name: "AbpEntityPropertyChanges",
                newName: "PhonebookEntityPropertyChanges");

            migrationBuilder.RenameTable(
                name: "AbpEntityChangeSets",
                newName: "PhonebookEntityChangeSets");

            migrationBuilder.RenameTable(
                name: "AbpEntityChanges",
                newName: "PhonebookEntityChanges");

            migrationBuilder.RenameTable(
                name: "AbpEditions",
                newName: "PhonebookEditions");

            migrationBuilder.RenameTable(
                name: "AbpBackgroundJobs",
                newName: "PhonebookBackgroundJobs");

            migrationBuilder.RenameTable(
                name: "AbpAuditLogs",
                newName: "PhonebookAuditLogs");

            migrationBuilder.RenameIndex(
                name: "IX_AbpUserTokens_TenantId_UserId",
                table: "PhonebookUserTokens",
                newName: "IX_PhonebookUserTokens_TenantId_UserId");

            migrationBuilder.RenameIndex(
                name: "IX_AbpUserTokens_UserId",
                table: "PhonebookUserTokens",
                newName: "IX_PhonebookUserTokens_UserId");

            migrationBuilder.RenameIndex(
                name: "IX_AbpUsers_TenantId_NormalizedUserName",
                table: "PhonebookUsers",
                newName: "IX_PhonebookUsers_TenantId_NormalizedUserName");

            migrationBuilder.RenameIndex(
                name: "IX_AbpUsers_TenantId_NormalizedEmailAddress",
                table: "PhonebookUsers",
                newName: "IX_PhonebookUsers_TenantId_NormalizedEmailAddress");

            migrationBuilder.RenameIndex(
                name: "IX_AbpUsers_LastModifierUserId",
                table: "PhonebookUsers",
                newName: "IX_PhonebookUsers_LastModifierUserId");

            migrationBuilder.RenameIndex(
                name: "IX_AbpUsers_DeleterUserId",
                table: "PhonebookUsers",
                newName: "IX_PhonebookUsers_DeleterUserId");

            migrationBuilder.RenameIndex(
                name: "IX_AbpUsers_CreatorUserId",
                table: "PhonebookUsers",
                newName: "IX_PhonebookUsers_CreatorUserId");

            migrationBuilder.RenameIndex(
                name: "IX_AbpUserRoles_TenantId_UserId",
                table: "PhonebookUserRoles",
                newName: "IX_PhonebookUserRoles_TenantId_UserId");

            migrationBuilder.RenameIndex(
                name: "IX_AbpUserRoles_TenantId_RoleId",
                table: "PhonebookUserRoles",
                newName: "IX_PhonebookUserRoles_TenantId_RoleId");

            migrationBuilder.RenameIndex(
                name: "IX_AbpUserRoles_UserId",
                table: "PhonebookUserRoles",
                newName: "IX_PhonebookUserRoles_UserId");

            migrationBuilder.RenameIndex(
                name: "IX_AbpUserOrganizationUnits_TenantId_UserId",
                table: "PhonebookUserOrganizationUnits",
                newName: "IX_PhonebookUserOrganizationUnits_TenantId_UserId");

            migrationBuilder.RenameIndex(
                name: "IX_AbpUserOrganizationUnits_TenantId_OrganizationUnitId",
                table: "PhonebookUserOrganizationUnits",
                newName: "IX_PhonebookUserOrganizationUnits_TenantId_OrganizationUnitId");

            migrationBuilder.RenameIndex(
                name: "IX_AbpUserNotifications_UserId_State_CreationTime",
                table: "PhonebookUserNotifications",
                newName: "IX_PhonebookUserNotifications_UserId_State_CreationTime");

            migrationBuilder.RenameIndex(
                name: "IX_AbpUserLogins_TenantId_LoginProvider_ProviderKey",
                table: "PhonebookUserLogins",
                newName: "IX_PhonebookUserLogins_TenantId_LoginProvider_ProviderKey");

            migrationBuilder.RenameIndex(
                name: "IX_AbpUserLogins_TenantId_UserId",
                table: "PhonebookUserLogins",
                newName: "IX_PhonebookUserLogins_TenantId_UserId");

            migrationBuilder.RenameIndex(
                name: "IX_AbpUserLogins_UserId",
                table: "PhonebookUserLogins",
                newName: "IX_PhonebookUserLogins_UserId");

            migrationBuilder.RenameIndex(
                name: "IX_AbpUserLoginAttempts_TenancyName_UserNameOrEmailAddress_Result",
                table: "PhonebookUserLoginAttempts",
                newName: "IX_PhonebookUserLoginAttempts_TenancyName_UserNameOrEmailAddress_Result");

            migrationBuilder.RenameIndex(
                name: "IX_AbpUserLoginAttempts_UserId_TenantId",
                table: "PhonebookUserLoginAttempts",
                newName: "IX_PhonebookUserLoginAttempts_UserId_TenantId");

            migrationBuilder.RenameIndex(
                name: "IX_AbpUserClaims_TenantId_ClaimType",
                table: "PhonebookUserClaims",
                newName: "IX_PhonebookUserClaims_TenantId_ClaimType");

            migrationBuilder.RenameIndex(
                name: "IX_AbpUserClaims_UserId",
                table: "PhonebookUserClaims",
                newName: "IX_PhonebookUserClaims_UserId");

            migrationBuilder.RenameIndex(
                name: "IX_AbpUserAccounts_TenantId_UserName",
                table: "PhonebookUserAccounts",
                newName: "IX_PhonebookUserAccounts_TenantId_UserName");

            migrationBuilder.RenameIndex(
                name: "IX_AbpUserAccounts_TenantId_UserId",
                table: "PhonebookUserAccounts",
                newName: "IX_PhonebookUserAccounts_TenantId_UserId");

            migrationBuilder.RenameIndex(
                name: "IX_AbpUserAccounts_TenantId_EmailAddress",
                table: "PhonebookUserAccounts",
                newName: "IX_PhonebookUserAccounts_TenantId_EmailAddress");

            migrationBuilder.RenameIndex(
                name: "IX_AbpUserAccounts_UserName",
                table: "PhonebookUserAccounts",
                newName: "IX_PhonebookUserAccounts_UserName");

            migrationBuilder.RenameIndex(
                name: "IX_AbpUserAccounts_EmailAddress",
                table: "PhonebookUserAccounts",
                newName: "IX_PhonebookUserAccounts_EmailAddress");

            migrationBuilder.RenameIndex(
                name: "IX_AbpTenants_TenancyName",
                table: "PhonebookTenants",
                newName: "IX_PhonebookTenants_TenancyName");

            migrationBuilder.RenameIndex(
                name: "IX_AbpTenants_LastModifierUserId",
                table: "PhonebookTenants",
                newName: "IX_PhonebookTenants_LastModifierUserId");

            migrationBuilder.RenameIndex(
                name: "IX_AbpTenants_EditionId",
                table: "PhonebookTenants",
                newName: "IX_PhonebookTenants_EditionId");

            migrationBuilder.RenameIndex(
                name: "IX_AbpTenants_DeleterUserId",
                table: "PhonebookTenants",
                newName: "IX_PhonebookTenants_DeleterUserId");

            migrationBuilder.RenameIndex(
                name: "IX_AbpTenants_CreatorUserId",
                table: "PhonebookTenants",
                newName: "IX_PhonebookTenants_CreatorUserId");

            migrationBuilder.RenameIndex(
                name: "IX_AbpTenantNotifications_TenantId",
                table: "PhonebookTenantNotifications",
                newName: "IX_PhonebookTenantNotifications_TenantId");

            migrationBuilder.RenameIndex(
                name: "IX_AbpSettings_TenantId_Name",
                table: "PhonebookSettings",
                newName: "IX_PhonebookSettings_TenantId_Name");

            migrationBuilder.RenameIndex(
                name: "IX_AbpSettings_UserId",
                table: "PhonebookSettings",
                newName: "IX_PhonebookSettings_UserId");

            migrationBuilder.RenameIndex(
                name: "IX_AbpRoles_TenantId_NormalizedName",
                table: "PhonebookRoles",
                newName: "IX_PhonebookRoles_TenantId_NormalizedName");

            migrationBuilder.RenameIndex(
                name: "IX_AbpRoles_LastModifierUserId",
                table: "PhonebookRoles",
                newName: "IX_PhonebookRoles_LastModifierUserId");

            migrationBuilder.RenameIndex(
                name: "IX_AbpRoles_DeleterUserId",
                table: "PhonebookRoles",
                newName: "IX_PhonebookRoles_DeleterUserId");

            migrationBuilder.RenameIndex(
                name: "IX_AbpRoles_CreatorUserId",
                table: "PhonebookRoles",
                newName: "IX_PhonebookRoles_CreatorUserId");

            migrationBuilder.RenameIndex(
                name: "IX_AbpRoleClaims_TenantId_ClaimType",
                table: "PhonebookRoleClaims",
                newName: "IX_PhonebookRoleClaims_TenantId_ClaimType");

            migrationBuilder.RenameIndex(
                name: "IX_AbpRoleClaims_RoleId",
                table: "PhonebookRoleClaims",
                newName: "IX_PhonebookRoleClaims_RoleId");

            migrationBuilder.RenameIndex(
                name: "IX_AbpPermissions_UserId",
                table: "PhonebookPermissions",
                newName: "IX_PhonebookPermissions_UserId");

            migrationBuilder.RenameIndex(
                name: "IX_AbpPermissions_RoleId",
                table: "PhonebookPermissions",
                newName: "IX_PhonebookPermissions_RoleId");

            migrationBuilder.RenameIndex(
                name: "IX_AbpPermissions_TenantId_Name",
                table: "PhonebookPermissions",
                newName: "IX_PhonebookPermissions_TenantId_Name");

            migrationBuilder.RenameIndex(
                name: "IX_AbpOrganizationUnits_TenantId_Code",
                table: "PhonebookOrganizationUnits",
                newName: "IX_PhonebookOrganizationUnits_TenantId_Code");

            migrationBuilder.RenameIndex(
                name: "IX_AbpOrganizationUnits_ParentId",
                table: "PhonebookOrganizationUnits",
                newName: "IX_PhonebookOrganizationUnits_ParentId");

            migrationBuilder.RenameIndex(
                name: "IX_AbpNotificationSubscriptions_TenantId_NotificationName_EntityTypeName_EntityId_UserId",
                table: "PhonebookNotificationSubscriptions",
                newName: "IX_PhonebookNotificationSubscriptions_TenantId_NotificationName_EntityTypeName_EntityId_UserId");

            migrationBuilder.RenameIndex(
                name: "IX_AbpNotificationSubscriptions_NotificationName_EntityTypeName_EntityId_UserId",
                table: "PhonebookNotificationSubscriptions",
                newName: "IX_PhonebookNotificationSubscriptions_NotificationName_EntityTypeName_EntityId_UserId");

            migrationBuilder.RenameIndex(
                name: "IX_AbpLanguageTexts_TenantId_Source_LanguageName_Key",
                table: "PhonebookLanguageTexts",
                newName: "IX_PhonebookLanguageTexts_TenantId_Source_LanguageName_Key");

            migrationBuilder.RenameIndex(
                name: "IX_AbpLanguages_TenantId_Name",
                table: "PhonebookLanguages",
                newName: "IX_PhonebookLanguages_TenantId_Name");

            migrationBuilder.RenameIndex(
                name: "IX_AbpFeatures_TenantId_Name",
                table: "PhonebookFeatures",
                newName: "IX_PhonebookFeatures_TenantId_Name");

            migrationBuilder.RenameIndex(
                name: "IX_AbpFeatures_EditionId_Name",
                table: "PhonebookFeatures",
                newName: "IX_PhonebookFeatures_EditionId_Name");

            migrationBuilder.RenameIndex(
                name: "IX_AbpEntityPropertyChanges_EntityChangeId",
                table: "PhonebookEntityPropertyChanges",
                newName: "IX_PhonebookEntityPropertyChanges_EntityChangeId");

            migrationBuilder.RenameIndex(
                name: "IX_AbpEntityChangeSets_TenantId_UserId",
                table: "PhonebookEntityChangeSets",
                newName: "IX_PhonebookEntityChangeSets_TenantId_UserId");

            migrationBuilder.RenameIndex(
                name: "IX_AbpEntityChangeSets_TenantId_Reason",
                table: "PhonebookEntityChangeSets",
                newName: "IX_PhonebookEntityChangeSets_TenantId_Reason");

            migrationBuilder.RenameIndex(
                name: "IX_AbpEntityChangeSets_TenantId_CreationTime",
                table: "PhonebookEntityChangeSets",
                newName: "IX_PhonebookEntityChangeSets_TenantId_CreationTime");

            migrationBuilder.RenameIndex(
                name: "IX_AbpEntityChanges_EntityTypeFullName_EntityId",
                table: "PhonebookEntityChanges",
                newName: "IX_PhonebookEntityChanges_EntityTypeFullName_EntityId");

            migrationBuilder.RenameIndex(
                name: "IX_AbpEntityChanges_EntityChangeSetId",
                table: "PhonebookEntityChanges",
                newName: "IX_PhonebookEntityChanges_EntityChangeSetId");

            migrationBuilder.RenameIndex(
                name: "IX_AbpBackgroundJobs_IsAbandoned_NextTryTime",
                table: "PhonebookBackgroundJobs",
                newName: "IX_PhonebookBackgroundJobs_IsAbandoned_NextTryTime");

            migrationBuilder.RenameIndex(
                name: "IX_AbpAuditLogs_TenantId_UserId",
                table: "PhonebookAuditLogs",
                newName: "IX_PhonebookAuditLogs_TenantId_UserId");

            migrationBuilder.RenameIndex(
                name: "IX_AbpAuditLogs_TenantId_ExecutionTime",
                table: "PhonebookAuditLogs",
                newName: "IX_PhonebookAuditLogs_TenantId_ExecutionTime");

            migrationBuilder.RenameIndex(
                name: "IX_AbpAuditLogs_TenantId_ExecutionDuration",
                table: "PhonebookAuditLogs",
                newName: "IX_PhonebookAuditLogs_TenantId_ExecutionDuration");

            migrationBuilder.AlterColumn<string>(
                name: "LoginProvider",
                table: "PhonebookUserTokens",
                maxLength: 128,
                nullable: true,
                oldClrType: typeof(string),
                oldMaxLength: 64,
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "Name",
                table: "PhonebookUsers",
                maxLength: 32,
                nullable: true,
                oldClrType: typeof(string),
                oldMaxLength: 32);

            migrationBuilder.AlterColumn<string>(
                name: "EmailAddress",
                table: "PhonebookUsers",
                maxLength: 256,
                nullable: true,
                oldClrType: typeof(string),
                oldMaxLength: 256);

            migrationBuilder.AddPrimaryKey(
                name: "PK_PhonebookUserTokens",
                table: "PhonebookUserTokens",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_PhonebookUsers",
                table: "PhonebookUsers",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_PhonebookUserRoles",
                table: "PhonebookUserRoles",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_PhonebookUserOrganizationUnits",
                table: "PhonebookUserOrganizationUnits",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_PhonebookUserNotifications",
                table: "PhonebookUserNotifications",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_PhonebookUserLogins",
                table: "PhonebookUserLogins",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_PhonebookUserLoginAttempts",
                table: "PhonebookUserLoginAttempts",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_PhonebookUserClaims",
                table: "PhonebookUserClaims",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_PhonebookUserAccounts",
                table: "PhonebookUserAccounts",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_PhonebookTenants",
                table: "PhonebookTenants",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_PhonebookTenantNotifications",
                table: "PhonebookTenantNotifications",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_PhonebookSettings",
                table: "PhonebookSettings",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_PhonebookRoles",
                table: "PhonebookRoles",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_PhonebookRoleClaims",
                table: "PhonebookRoleClaims",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_PhonebookPermissions",
                table: "PhonebookPermissions",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_PhonebookOrganizationUnits",
                table: "PhonebookOrganizationUnits",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_PhonebookNotificationSubscriptions",
                table: "PhonebookNotificationSubscriptions",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_PhonebookNotifications",
                table: "PhonebookNotifications",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_PhonebookLanguageTexts",
                table: "PhonebookLanguageTexts",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_PhonebookLanguages",
                table: "PhonebookLanguages",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_PhonebookFeatures",
                table: "PhonebookFeatures",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_PhonebookEntityPropertyChanges",
                table: "PhonebookEntityPropertyChanges",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_PhonebookEntityChangeSets",
                table: "PhonebookEntityChangeSets",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_PhonebookEntityChanges",
                table: "PhonebookEntityChanges",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_PhonebookEditions",
                table: "PhonebookEditions",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_PhonebookBackgroundJobs",
                table: "PhonebookBackgroundJobs",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_PhonebookAuditLogs",
                table: "PhonebookAuditLogs",
                column: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_PhonebookEntityChanges_PhonebookEntityChangeSets_EntityChangeSetId",
                table: "PhonebookEntityChanges",
                column: "EntityChangeSetId",
                principalTable: "PhonebookEntityChangeSets",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_PhonebookEntityPropertyChanges_PhonebookEntityChanges_EntityChangeId",
                table: "PhonebookEntityPropertyChanges",
                column: "EntityChangeId",
                principalTable: "PhonebookEntityChanges",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_PhonebookFeatures_PhonebookEditions_EditionId",
                table: "PhonebookFeatures",
                column: "EditionId",
                principalTable: "PhonebookEditions",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_PhonebookOrganizationUnits_PhonebookOrganizationUnits_ParentId",
                table: "PhonebookOrganizationUnits",
                column: "ParentId",
                principalTable: "PhonebookOrganizationUnits",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_PhonebookPermissions_PhonebookRoles_RoleId",
                table: "PhonebookPermissions",
                column: "RoleId",
                principalTable: "PhonebookRoles",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_PhonebookPermissions_PhonebookUsers_UserId",
                table: "PhonebookPermissions",
                column: "UserId",
                principalTable: "PhonebookUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_PhonebookRoleClaims_PhonebookRoles_RoleId",
                table: "PhonebookRoleClaims",
                column: "RoleId",
                principalTable: "PhonebookRoles",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_PhonebookRoles_PhonebookUsers_CreatorUserId",
                table: "PhonebookRoles",
                column: "CreatorUserId",
                principalTable: "PhonebookUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_PhonebookRoles_PhonebookUsers_DeleterUserId",
                table: "PhonebookRoles",
                column: "DeleterUserId",
                principalTable: "PhonebookUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_PhonebookRoles_PhonebookUsers_LastModifierUserId",
                table: "PhonebookRoles",
                column: "LastModifierUserId",
                principalTable: "PhonebookUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_PhonebookSettings_PhonebookUsers_UserId",
                table: "PhonebookSettings",
                column: "UserId",
                principalTable: "PhonebookUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_PhonebookTenants_PhonebookUsers_CreatorUserId",
                table: "PhonebookTenants",
                column: "CreatorUserId",
                principalTable: "PhonebookUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_PhonebookTenants_PhonebookUsers_DeleterUserId",
                table: "PhonebookTenants",
                column: "DeleterUserId",
                principalTable: "PhonebookUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_PhonebookTenants_PhonebookEditions_EditionId",
                table: "PhonebookTenants",
                column: "EditionId",
                principalTable: "PhonebookEditions",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_PhonebookTenants_PhonebookUsers_LastModifierUserId",
                table: "PhonebookTenants",
                column: "LastModifierUserId",
                principalTable: "PhonebookUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_PhonebookUserClaims_PhonebookUsers_UserId",
                table: "PhonebookUserClaims",
                column: "UserId",
                principalTable: "PhonebookUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_PhonebookUserLogins_PhonebookUsers_UserId",
                table: "PhonebookUserLogins",
                column: "UserId",
                principalTable: "PhonebookUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_PhonebookUserRoles_PhonebookUsers_UserId",
                table: "PhonebookUserRoles",
                column: "UserId",
                principalTable: "PhonebookUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_PhonebookUsers_PhonebookUsers_CreatorUserId",
                table: "PhonebookUsers",
                column: "CreatorUserId",
                principalTable: "PhonebookUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_PhonebookUsers_PhonebookUsers_DeleterUserId",
                table: "PhonebookUsers",
                column: "DeleterUserId",
                principalTable: "PhonebookUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_PhonebookUsers_PhonebookUsers_LastModifierUserId",
                table: "PhonebookUsers",
                column: "LastModifierUserId",
                principalTable: "PhonebookUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_PhonebookUserTokens_PhonebookUsers_UserId",
                table: "PhonebookUserTokens",
                column: "UserId",
                principalTable: "PhonebookUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_PhonebookEntityChanges_PhonebookEntityChangeSets_EntityChangeSetId",
                table: "PhonebookEntityChanges");

            migrationBuilder.DropForeignKey(
                name: "FK_PhonebookEntityPropertyChanges_PhonebookEntityChanges_EntityChangeId",
                table: "PhonebookEntityPropertyChanges");

            migrationBuilder.DropForeignKey(
                name: "FK_PhonebookFeatures_PhonebookEditions_EditionId",
                table: "PhonebookFeatures");

            migrationBuilder.DropForeignKey(
                name: "FK_PhonebookOrganizationUnits_PhonebookOrganizationUnits_ParentId",
                table: "PhonebookOrganizationUnits");

            migrationBuilder.DropForeignKey(
                name: "FK_PhonebookPermissions_PhonebookRoles_RoleId",
                table: "PhonebookPermissions");

            migrationBuilder.DropForeignKey(
                name: "FK_PhonebookPermissions_PhonebookUsers_UserId",
                table: "PhonebookPermissions");

            migrationBuilder.DropForeignKey(
                name: "FK_PhonebookRoleClaims_PhonebookRoles_RoleId",
                table: "PhonebookRoleClaims");

            migrationBuilder.DropForeignKey(
                name: "FK_PhonebookRoles_PhonebookUsers_CreatorUserId",
                table: "PhonebookRoles");

            migrationBuilder.DropForeignKey(
                name: "FK_PhonebookRoles_PhonebookUsers_DeleterUserId",
                table: "PhonebookRoles");

            migrationBuilder.DropForeignKey(
                name: "FK_PhonebookRoles_PhonebookUsers_LastModifierUserId",
                table: "PhonebookRoles");

            migrationBuilder.DropForeignKey(
                name: "FK_PhonebookSettings_PhonebookUsers_UserId",
                table: "PhonebookSettings");

            migrationBuilder.DropForeignKey(
                name: "FK_PhonebookTenants_PhonebookUsers_CreatorUserId",
                table: "PhonebookTenants");

            migrationBuilder.DropForeignKey(
                name: "FK_PhonebookTenants_PhonebookUsers_DeleterUserId",
                table: "PhonebookTenants");

            migrationBuilder.DropForeignKey(
                name: "FK_PhonebookTenants_PhonebookEditions_EditionId",
                table: "PhonebookTenants");

            migrationBuilder.DropForeignKey(
                name: "FK_PhonebookTenants_PhonebookUsers_LastModifierUserId",
                table: "PhonebookTenants");

            migrationBuilder.DropForeignKey(
                name: "FK_PhonebookUserClaims_PhonebookUsers_UserId",
                table: "PhonebookUserClaims");

            migrationBuilder.DropForeignKey(
                name: "FK_PhonebookUserLogins_PhonebookUsers_UserId",
                table: "PhonebookUserLogins");

            migrationBuilder.DropForeignKey(
                name: "FK_PhonebookUserRoles_PhonebookUsers_UserId",
                table: "PhonebookUserRoles");

            migrationBuilder.DropForeignKey(
                name: "FK_PhonebookUsers_PhonebookUsers_CreatorUserId",
                table: "PhonebookUsers");

            migrationBuilder.DropForeignKey(
                name: "FK_PhonebookUsers_PhonebookUsers_DeleterUserId",
                table: "PhonebookUsers");

            migrationBuilder.DropForeignKey(
                name: "FK_PhonebookUsers_PhonebookUsers_LastModifierUserId",
                table: "PhonebookUsers");

            migrationBuilder.DropForeignKey(
                name: "FK_PhonebookUserTokens_PhonebookUsers_UserId",
                table: "PhonebookUserTokens");

            migrationBuilder.DropPrimaryKey(
                name: "PK_PhonebookUserTokens",
                table: "PhonebookUserTokens");

            migrationBuilder.DropPrimaryKey(
                name: "PK_PhonebookUsers",
                table: "PhonebookUsers");

            migrationBuilder.DropPrimaryKey(
                name: "PK_PhonebookUserRoles",
                table: "PhonebookUserRoles");

            migrationBuilder.DropPrimaryKey(
                name: "PK_PhonebookUserOrganizationUnits",
                table: "PhonebookUserOrganizationUnits");

            migrationBuilder.DropPrimaryKey(
                name: "PK_PhonebookUserNotifications",
                table: "PhonebookUserNotifications");

            migrationBuilder.DropPrimaryKey(
                name: "PK_PhonebookUserLogins",
                table: "PhonebookUserLogins");

            migrationBuilder.DropPrimaryKey(
                name: "PK_PhonebookUserLoginAttempts",
                table: "PhonebookUserLoginAttempts");

            migrationBuilder.DropPrimaryKey(
                name: "PK_PhonebookUserClaims",
                table: "PhonebookUserClaims");

            migrationBuilder.DropPrimaryKey(
                name: "PK_PhonebookUserAccounts",
                table: "PhonebookUserAccounts");

            migrationBuilder.DropPrimaryKey(
                name: "PK_PhonebookTenants",
                table: "PhonebookTenants");

            migrationBuilder.DropPrimaryKey(
                name: "PK_PhonebookTenantNotifications",
                table: "PhonebookTenantNotifications");

            migrationBuilder.DropPrimaryKey(
                name: "PK_PhonebookSettings",
                table: "PhonebookSettings");

            migrationBuilder.DropPrimaryKey(
                name: "PK_PhonebookRoles",
                table: "PhonebookRoles");

            migrationBuilder.DropPrimaryKey(
                name: "PK_PhonebookRoleClaims",
                table: "PhonebookRoleClaims");

            migrationBuilder.DropPrimaryKey(
                name: "PK_PhonebookPermissions",
                table: "PhonebookPermissions");

            migrationBuilder.DropPrimaryKey(
                name: "PK_PhonebookOrganizationUnits",
                table: "PhonebookOrganizationUnits");

            migrationBuilder.DropPrimaryKey(
                name: "PK_PhonebookNotificationSubscriptions",
                table: "PhonebookNotificationSubscriptions");

            migrationBuilder.DropPrimaryKey(
                name: "PK_PhonebookNotifications",
                table: "PhonebookNotifications");

            migrationBuilder.DropPrimaryKey(
                name: "PK_PhonebookLanguageTexts",
                table: "PhonebookLanguageTexts");

            migrationBuilder.DropPrimaryKey(
                name: "PK_PhonebookLanguages",
                table: "PhonebookLanguages");

            migrationBuilder.DropPrimaryKey(
                name: "PK_PhonebookFeatures",
                table: "PhonebookFeatures");

            migrationBuilder.DropPrimaryKey(
                name: "PK_PhonebookEntityPropertyChanges",
                table: "PhonebookEntityPropertyChanges");

            migrationBuilder.DropPrimaryKey(
                name: "PK_PhonebookEntityChangeSets",
                table: "PhonebookEntityChangeSets");

            migrationBuilder.DropPrimaryKey(
                name: "PK_PhonebookEntityChanges",
                table: "PhonebookEntityChanges");

            migrationBuilder.DropPrimaryKey(
                name: "PK_PhonebookEditions",
                table: "PhonebookEditions");

            migrationBuilder.DropPrimaryKey(
                name: "PK_PhonebookBackgroundJobs",
                table: "PhonebookBackgroundJobs");

            migrationBuilder.DropPrimaryKey(
                name: "PK_PhonebookAuditLogs",
                table: "PhonebookAuditLogs");

            migrationBuilder.RenameTable(
                name: "PhonebookUserTokens",
                newName: "AbpUserTokens");

            migrationBuilder.RenameTable(
                name: "PhonebookUsers",
                newName: "AbpUsers");

            migrationBuilder.RenameTable(
                name: "PhonebookUserRoles",
                newName: "AbpUserRoles");

            migrationBuilder.RenameTable(
                name: "PhonebookUserOrganizationUnits",
                newName: "AbpUserOrganizationUnits");

            migrationBuilder.RenameTable(
                name: "PhonebookUserNotifications",
                newName: "AbpUserNotifications");

            migrationBuilder.RenameTable(
                name: "PhonebookUserLogins",
                newName: "AbpUserLogins");

            migrationBuilder.RenameTable(
                name: "PhonebookUserLoginAttempts",
                newName: "AbpUserLoginAttempts");

            migrationBuilder.RenameTable(
                name: "PhonebookUserClaims",
                newName: "AbpUserClaims");

            migrationBuilder.RenameTable(
                name: "PhonebookUserAccounts",
                newName: "AbpUserAccounts");

            migrationBuilder.RenameTable(
                name: "PhonebookTenants",
                newName: "AbpTenants");

            migrationBuilder.RenameTable(
                name: "PhonebookTenantNotifications",
                newName: "AbpTenantNotifications");

            migrationBuilder.RenameTable(
                name: "PhonebookSettings",
                newName: "AbpSettings");

            migrationBuilder.RenameTable(
                name: "PhonebookRoles",
                newName: "AbpRoles");

            migrationBuilder.RenameTable(
                name: "PhonebookRoleClaims",
                newName: "AbpRoleClaims");

            migrationBuilder.RenameTable(
                name: "PhonebookPermissions",
                newName: "AbpPermissions");

            migrationBuilder.RenameTable(
                name: "PhonebookOrganizationUnits",
                newName: "AbpOrganizationUnits");

            migrationBuilder.RenameTable(
                name: "PhonebookNotificationSubscriptions",
                newName: "AbpNotificationSubscriptions");

            migrationBuilder.RenameTable(
                name: "PhonebookNotifications",
                newName: "AbpNotifications");

            migrationBuilder.RenameTable(
                name: "PhonebookLanguageTexts",
                newName: "AbpLanguageTexts");

            migrationBuilder.RenameTable(
                name: "PhonebookLanguages",
                newName: "AbpLanguages");

            migrationBuilder.RenameTable(
                name: "PhonebookFeatures",
                newName: "AbpFeatures");

            migrationBuilder.RenameTable(
                name: "PhonebookEntityPropertyChanges",
                newName: "AbpEntityPropertyChanges");

            migrationBuilder.RenameTable(
                name: "PhonebookEntityChangeSets",
                newName: "AbpEntityChangeSets");

            migrationBuilder.RenameTable(
                name: "PhonebookEntityChanges",
                newName: "AbpEntityChanges");

            migrationBuilder.RenameTable(
                name: "PhonebookEditions",
                newName: "AbpEditions");

            migrationBuilder.RenameTable(
                name: "PhonebookBackgroundJobs",
                newName: "AbpBackgroundJobs");

            migrationBuilder.RenameTable(
                name: "PhonebookAuditLogs",
                newName: "AbpAuditLogs");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookUserTokens_TenantId_UserId",
                table: "AbpUserTokens",
                newName: "IX_AbpUserTokens_TenantId_UserId");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookUserTokens_UserId",
                table: "AbpUserTokens",
                newName: "IX_AbpUserTokens_UserId");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookUsers_TenantId_NormalizedUserName",
                table: "AbpUsers",
                newName: "IX_AbpUsers_TenantId_NormalizedUserName");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookUsers_TenantId_NormalizedEmailAddress",
                table: "AbpUsers",
                newName: "IX_AbpUsers_TenantId_NormalizedEmailAddress");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookUsers_LastModifierUserId",
                table: "AbpUsers",
                newName: "IX_AbpUsers_LastModifierUserId");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookUsers_DeleterUserId",
                table: "AbpUsers",
                newName: "IX_AbpUsers_DeleterUserId");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookUsers_CreatorUserId",
                table: "AbpUsers",
                newName: "IX_AbpUsers_CreatorUserId");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookUserRoles_TenantId_UserId",
                table: "AbpUserRoles",
                newName: "IX_AbpUserRoles_TenantId_UserId");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookUserRoles_TenantId_RoleId",
                table: "AbpUserRoles",
                newName: "IX_AbpUserRoles_TenantId_RoleId");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookUserRoles_UserId",
                table: "AbpUserRoles",
                newName: "IX_AbpUserRoles_UserId");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookUserOrganizationUnits_TenantId_UserId",
                table: "AbpUserOrganizationUnits",
                newName: "IX_AbpUserOrganizationUnits_TenantId_UserId");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookUserOrganizationUnits_TenantId_OrganizationUnitId",
                table: "AbpUserOrganizationUnits",
                newName: "IX_AbpUserOrganizationUnits_TenantId_OrganizationUnitId");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookUserNotifications_UserId_State_CreationTime",
                table: "AbpUserNotifications",
                newName: "IX_AbpUserNotifications_UserId_State_CreationTime");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookUserLogins_TenantId_LoginProvider_ProviderKey",
                table: "AbpUserLogins",
                newName: "IX_AbpUserLogins_TenantId_LoginProvider_ProviderKey");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookUserLogins_TenantId_UserId",
                table: "AbpUserLogins",
                newName: "IX_AbpUserLogins_TenantId_UserId");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookUserLogins_UserId",
                table: "AbpUserLogins",
                newName: "IX_AbpUserLogins_UserId");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookUserLoginAttempts_TenancyName_UserNameOrEmailAddress_Result",
                table: "AbpUserLoginAttempts",
                newName: "IX_AbpUserLoginAttempts_TenancyName_UserNameOrEmailAddress_Result");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookUserLoginAttempts_UserId_TenantId",
                table: "AbpUserLoginAttempts",
                newName: "IX_AbpUserLoginAttempts_UserId_TenantId");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookUserClaims_TenantId_ClaimType",
                table: "AbpUserClaims",
                newName: "IX_AbpUserClaims_TenantId_ClaimType");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookUserClaims_UserId",
                table: "AbpUserClaims",
                newName: "IX_AbpUserClaims_UserId");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookUserAccounts_TenantId_UserName",
                table: "AbpUserAccounts",
                newName: "IX_AbpUserAccounts_TenantId_UserName");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookUserAccounts_TenantId_UserId",
                table: "AbpUserAccounts",
                newName: "IX_AbpUserAccounts_TenantId_UserId");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookUserAccounts_TenantId_EmailAddress",
                table: "AbpUserAccounts",
                newName: "IX_AbpUserAccounts_TenantId_EmailAddress");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookUserAccounts_UserName",
                table: "AbpUserAccounts",
                newName: "IX_AbpUserAccounts_UserName");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookUserAccounts_EmailAddress",
                table: "AbpUserAccounts",
                newName: "IX_AbpUserAccounts_EmailAddress");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookTenants_TenancyName",
                table: "AbpTenants",
                newName: "IX_AbpTenants_TenancyName");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookTenants_LastModifierUserId",
                table: "AbpTenants",
                newName: "IX_AbpTenants_LastModifierUserId");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookTenants_EditionId",
                table: "AbpTenants",
                newName: "IX_AbpTenants_EditionId");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookTenants_DeleterUserId",
                table: "AbpTenants",
                newName: "IX_AbpTenants_DeleterUserId");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookTenants_CreatorUserId",
                table: "AbpTenants",
                newName: "IX_AbpTenants_CreatorUserId");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookTenantNotifications_TenantId",
                table: "AbpTenantNotifications",
                newName: "IX_AbpTenantNotifications_TenantId");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookSettings_TenantId_Name",
                table: "AbpSettings",
                newName: "IX_AbpSettings_TenantId_Name");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookSettings_UserId",
                table: "AbpSettings",
                newName: "IX_AbpSettings_UserId");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookRoles_TenantId_NormalizedName",
                table: "AbpRoles",
                newName: "IX_AbpRoles_TenantId_NormalizedName");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookRoles_LastModifierUserId",
                table: "AbpRoles",
                newName: "IX_AbpRoles_LastModifierUserId");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookRoles_DeleterUserId",
                table: "AbpRoles",
                newName: "IX_AbpRoles_DeleterUserId");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookRoles_CreatorUserId",
                table: "AbpRoles",
                newName: "IX_AbpRoles_CreatorUserId");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookRoleClaims_TenantId_ClaimType",
                table: "AbpRoleClaims",
                newName: "IX_AbpRoleClaims_TenantId_ClaimType");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookRoleClaims_RoleId",
                table: "AbpRoleClaims",
                newName: "IX_AbpRoleClaims_RoleId");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookPermissions_UserId",
                table: "AbpPermissions",
                newName: "IX_AbpPermissions_UserId");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookPermissions_RoleId",
                table: "AbpPermissions",
                newName: "IX_AbpPermissions_RoleId");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookPermissions_TenantId_Name",
                table: "AbpPermissions",
                newName: "IX_AbpPermissions_TenantId_Name");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookOrganizationUnits_TenantId_Code",
                table: "AbpOrganizationUnits",
                newName: "IX_AbpOrganizationUnits_TenantId_Code");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookOrganizationUnits_ParentId",
                table: "AbpOrganizationUnits",
                newName: "IX_AbpOrganizationUnits_ParentId");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookNotificationSubscriptions_TenantId_NotificationName_EntityTypeName_EntityId_UserId",
                table: "AbpNotificationSubscriptions",
                newName: "IX_AbpNotificationSubscriptions_TenantId_NotificationName_EntityTypeName_EntityId_UserId");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookNotificationSubscriptions_NotificationName_EntityTypeName_EntityId_UserId",
                table: "AbpNotificationSubscriptions",
                newName: "IX_AbpNotificationSubscriptions_NotificationName_EntityTypeName_EntityId_UserId");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookLanguageTexts_TenantId_Source_LanguageName_Key",
                table: "AbpLanguageTexts",
                newName: "IX_AbpLanguageTexts_TenantId_Source_LanguageName_Key");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookLanguages_TenantId_Name",
                table: "AbpLanguages",
                newName: "IX_AbpLanguages_TenantId_Name");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookFeatures_TenantId_Name",
                table: "AbpFeatures",
                newName: "IX_AbpFeatures_TenantId_Name");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookFeatures_EditionId_Name",
                table: "AbpFeatures",
                newName: "IX_AbpFeatures_EditionId_Name");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookEntityPropertyChanges_EntityChangeId",
                table: "AbpEntityPropertyChanges",
                newName: "IX_AbpEntityPropertyChanges_EntityChangeId");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookEntityChangeSets_TenantId_UserId",
                table: "AbpEntityChangeSets",
                newName: "IX_AbpEntityChangeSets_TenantId_UserId");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookEntityChangeSets_TenantId_Reason",
                table: "AbpEntityChangeSets",
                newName: "IX_AbpEntityChangeSets_TenantId_Reason");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookEntityChangeSets_TenantId_CreationTime",
                table: "AbpEntityChangeSets",
                newName: "IX_AbpEntityChangeSets_TenantId_CreationTime");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookEntityChanges_EntityTypeFullName_EntityId",
                table: "AbpEntityChanges",
                newName: "IX_AbpEntityChanges_EntityTypeFullName_EntityId");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookEntityChanges_EntityChangeSetId",
                table: "AbpEntityChanges",
                newName: "IX_AbpEntityChanges_EntityChangeSetId");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookBackgroundJobs_IsAbandoned_NextTryTime",
                table: "AbpBackgroundJobs",
                newName: "IX_AbpBackgroundJobs_IsAbandoned_NextTryTime");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookAuditLogs_TenantId_UserId",
                table: "AbpAuditLogs",
                newName: "IX_AbpAuditLogs_TenantId_UserId");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookAuditLogs_TenantId_ExecutionTime",
                table: "AbpAuditLogs",
                newName: "IX_AbpAuditLogs_TenantId_ExecutionTime");

            migrationBuilder.RenameIndex(
                name: "IX_PhonebookAuditLogs_TenantId_ExecutionDuration",
                table: "AbpAuditLogs",
                newName: "IX_AbpAuditLogs_TenantId_ExecutionDuration");

            migrationBuilder.AlterColumn<string>(
                name: "LoginProvider",
                table: "AbpUserTokens",
                maxLength: 64,
                nullable: true,
                oldClrType: typeof(string),
                oldMaxLength: 128,
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "Name",
                table: "AbpUsers",
                maxLength: 32,
                nullable: false,
                oldClrType: typeof(string),
                oldMaxLength: 32,
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "EmailAddress",
                table: "AbpUsers",
                maxLength: 256,
                nullable: false,
                oldClrType: typeof(string),
                oldMaxLength: 256,
                oldNullable: true);

            migrationBuilder.AddColumn<string>(
                name: "Surname",
                table: "AbpUsers",
                maxLength: 32,
                nullable: false,
                defaultValue: "");

            migrationBuilder.AddPrimaryKey(
                name: "PK_AbpUserTokens",
                table: "AbpUserTokens",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_AbpUsers",
                table: "AbpUsers",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_AbpUserRoles",
                table: "AbpUserRoles",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_AbpUserOrganizationUnits",
                table: "AbpUserOrganizationUnits",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_AbpUserNotifications",
                table: "AbpUserNotifications",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_AbpUserLogins",
                table: "AbpUserLogins",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_AbpUserLoginAttempts",
                table: "AbpUserLoginAttempts",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_AbpUserClaims",
                table: "AbpUserClaims",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_AbpUserAccounts",
                table: "AbpUserAccounts",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_AbpTenants",
                table: "AbpTenants",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_AbpTenantNotifications",
                table: "AbpTenantNotifications",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_AbpSettings",
                table: "AbpSettings",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_AbpRoles",
                table: "AbpRoles",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_AbpRoleClaims",
                table: "AbpRoleClaims",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_AbpPermissions",
                table: "AbpPermissions",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_AbpOrganizationUnits",
                table: "AbpOrganizationUnits",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_AbpNotificationSubscriptions",
                table: "AbpNotificationSubscriptions",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_AbpNotifications",
                table: "AbpNotifications",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_AbpLanguageTexts",
                table: "AbpLanguageTexts",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_AbpLanguages",
                table: "AbpLanguages",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_AbpFeatures",
                table: "AbpFeatures",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_AbpEntityPropertyChanges",
                table: "AbpEntityPropertyChanges",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_AbpEntityChangeSets",
                table: "AbpEntityChangeSets",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_AbpEntityChanges",
                table: "AbpEntityChanges",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_AbpEditions",
                table: "AbpEditions",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_AbpBackgroundJobs",
                table: "AbpBackgroundJobs",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_AbpAuditLogs",
                table: "AbpAuditLogs",
                column: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_AbpEntityChanges_AbpEntityChangeSets_EntityChangeSetId",
                table: "AbpEntityChanges",
                column: "EntityChangeSetId",
                principalTable: "AbpEntityChangeSets",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_AbpEntityPropertyChanges_AbpEntityChanges_EntityChangeId",
                table: "AbpEntityPropertyChanges",
                column: "EntityChangeId",
                principalTable: "AbpEntityChanges",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_AbpFeatures_AbpEditions_EditionId",
                table: "AbpFeatures",
                column: "EditionId",
                principalTable: "AbpEditions",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_AbpOrganizationUnits_AbpOrganizationUnits_ParentId",
                table: "AbpOrganizationUnits",
                column: "ParentId",
                principalTable: "AbpOrganizationUnits",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_AbpPermissions_AbpRoles_RoleId",
                table: "AbpPermissions",
                column: "RoleId",
                principalTable: "AbpRoles",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_AbpPermissions_AbpUsers_UserId",
                table: "AbpPermissions",
                column: "UserId",
                principalTable: "AbpUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_AbpRoleClaims_AbpRoles_RoleId",
                table: "AbpRoleClaims",
                column: "RoleId",
                principalTable: "AbpRoles",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_AbpRoles_AbpUsers_CreatorUserId",
                table: "AbpRoles",
                column: "CreatorUserId",
                principalTable: "AbpUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_AbpRoles_AbpUsers_DeleterUserId",
                table: "AbpRoles",
                column: "DeleterUserId",
                principalTable: "AbpUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_AbpRoles_AbpUsers_LastModifierUserId",
                table: "AbpRoles",
                column: "LastModifierUserId",
                principalTable: "AbpUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_AbpSettings_AbpUsers_UserId",
                table: "AbpSettings",
                column: "UserId",
                principalTable: "AbpUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_AbpTenants_AbpUsers_CreatorUserId",
                table: "AbpTenants",
                column: "CreatorUserId",
                principalTable: "AbpUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_AbpTenants_AbpUsers_DeleterUserId",
                table: "AbpTenants",
                column: "DeleterUserId",
                principalTable: "AbpUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_AbpTenants_AbpEditions_EditionId",
                table: "AbpTenants",
                column: "EditionId",
                principalTable: "AbpEditions",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_AbpTenants_AbpUsers_LastModifierUserId",
                table: "AbpTenants",
                column: "LastModifierUserId",
                principalTable: "AbpUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_AbpUserClaims_AbpUsers_UserId",
                table: "AbpUserClaims",
                column: "UserId",
                principalTable: "AbpUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_AbpUserLogins_AbpUsers_UserId",
                table: "AbpUserLogins",
                column: "UserId",
                principalTable: "AbpUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_AbpUserRoles_AbpUsers_UserId",
                table: "AbpUserRoles",
                column: "UserId",
                principalTable: "AbpUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_AbpUsers_AbpUsers_CreatorUserId",
                table: "AbpUsers",
                column: "CreatorUserId",
                principalTable: "AbpUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_AbpUsers_AbpUsers_DeleterUserId",
                table: "AbpUsers",
                column: "DeleterUserId",
                principalTable: "AbpUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_AbpUsers_AbpUsers_LastModifierUserId",
                table: "AbpUsers",
                column: "LastModifierUserId",
                principalTable: "AbpUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_AbpUserTokens_AbpUsers_UserId",
                table: "AbpUserTokens",
                column: "UserId",
                principalTable: "AbpUsers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
    }
}
